{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "01bab498-b6d8-4ece-916f-e6e98943a3a6",
   "metadata": {},
   "outputs": [],
   "source": [
    "prompt = \"\"\"使用上下文数据: {context}\n",
    "\n",
    "生成至少 {num_questions} 个可能的用户问题，这些问题可以在该上下文中直接回答。确保问题没有包含任何答案或标题。每个问题之间用换行符分隔。\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "7acb07d3-9c81-4c55-96df-ebacf969f8f7",
   "metadata": {},
   "outputs": [],
   "source": [
    "text = \"\"\"蔚来萤火虫即将交付，李斌所预测的两年内新能源车渗透率超80%能否实现？\n",
    "\n",
    "9 月 6 日消息，近日，蔚来汽车创始人、董事长李斌在蔚来九周年内部讲话及财报电话会上透露了多项重要信息，其中最引人注目的莫过于第三品牌萤火虫将于 2025 年正式交付，并预测新能源汽车的市场渗透率将在未来两年内超过 80%。\n",
    "\n",
    "据李斌介绍，蔚来汽车将形成三个品牌矩阵，覆盖从 14 万元到 80 万元的广阔市场区间。其中，第三品牌萤火虫作为蔚来汽车布局中低端市场的重要棋子，将于 2025 年正式交付。这一举措不仅丰富了蔚来的产品线，也进一步提升了其在新能源汽车市场的竞争力。\n",
    "\n",
    "This chunker works by determining when to \"break\" apart sentences. This is done by looking for differences in embeddings between any two sentences. When that difference is past some threshold, then they are split.\n",
    "\n",
    "There are a few ways to determine what that threshold is, which are controlled by the breakpoint_threshold_type kwarg.\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "5c20706a-7251-4a09-a54a-0f17b622d8f5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "蔚来汽车的第三品牌萤火虫预计何时交付？\n",
      "\n",
      "李斌预测的新能源汽车市场渗透率目标是多少？\n",
      "\n",
      "蔚来汽车将如何覆盖不同价格区间的新能源汽车市场？\n",
      "\n",
      "蔚来汽车计划形成的三个品牌矩阵具体是什么？\n",
      "\n",
      "李斌在蔚来九周年内部讲话中透露了哪些重要信息？\n"
     ]
    }
   ],
   "source": [
    "from zhipuai import ZhipuAI\n",
    "client = ZhipuAI(api_key=\"f97b28aa71892d6d515007ef44ee5de6.WvLXD1MsFsGklOZa\") # 填写您自己的APIKey\n",
    "\n",
    "def llm_engine(messages, stop_sequences=None):\n",
    "    response = client.chat.completions.create(\n",
    "        model=\"glm-4-plus\", \n",
    "        messages=messages,\n",
    "        stop=stop_sequences\n",
    "    )\n",
    "    return response.choices[0].message.content\n",
    "\n",
    "print(llm_engine([{'role':'user','content':prompt.format_map({'context':text,'num_questions':5})}]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f3bf4cf8-340e-4eb3-8d56-ab247bf7c6fd",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 对每个chunk生产猜测的用户问题  metadata可以存储原始chunk"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4cd62da5-c9a4-48a8-b3d2-c292ce7e737b",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9c09ba8a-f16b-47ec-90c7-0b7e85749d38",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.0rc2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
